Skip to content

Conversation

@zharinov
Copy link
Member

@zharinov zharinov commented Jan 4, 2026

Summary

Adds regression test for BUG #6: Tagged alternation used wrong $tag when branches reference named definitions.

The fix is already in master. This PR adds the regression test to prevent future regressions.

The Bug

When a definition name (e.g., Second) is interned before a branch label (e.g., First), the enum member indices would mismatch because:

  • Enum members are emitted in BTreeMap (Symbol interning) order
  • But the compiler was using AST branch order for member indices

Test Case

Second = (binary_expression left: (number) @left right: (number) @right)
Q = (program (expression_statement [First: (number) @num  Second: (Second) @bin]))

With input 42, the output should be {"$tag": "First", ...} (not "Second").

BUG #6: Tagged alternation used wrong $tag when branches reference named
definitions. The fix is already in master - this adds the regression test.
@zharinov zharinov merged commit d10b3c6 into master Jan 4, 2026
4 checks passed
@zharinov zharinov deleted the test/enum-tag-regression branch January 4, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants